  import * as echarts from 'echarts'
  const setOption:any = {
    Line(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      var seriesArr = []
      for (var i = 0; i <= attr.legendArr.length-1; i++) {
        colorArr.push(colorList[i].colorStart)
        seriesArr.push({ 
          name: attr.legendArr[i],
          type: 'line', 
          connectNulls:true,
          smooth: true,
          sampling: 'average', 
          large: true,
          animation: false,
          clip: true,  
          lineStyle:{ color:colorArr[i] }, 
          yAxisIndex: 0,
          data: [],
        })
      }
      let grid = [{ left: '0%', bottom: '0%', right: '5%', height: "80%", containLabel: true}]
      let tooltip = { backgroundColor:'rgba(0,0,0,0.5)',
        textStyle : { color: '#FFFFFF'}, trigger: 'item', show: true,
        formatter: function (params:any) {
          let k = params.value[0]
          let v = params.value[1]
          if(v.toString().split(".")[1] && v.toString().split(".")[1].length >3) v = Math.floor((v*100)/100)
          return '时间：' + k + '<br />值：' + v + ' ' + (attr.dw?attr.dw:'') 
        }
      }
      let dataZoom = [{ type: 'inside', show : true, realtime : true, startValue: 0, endValue: attr.chart_type==0? 20 : 100 }]
      let xAxis = { type: 'category', boundaryGap: false,
        // 轴线
        axisLine: { lineStyle: { color: '#113D72', fontSize: 12, type: 'dashed' }},
        //刻度线
        axisTick: { show: false},
        // 分割线
        splitLine: { show: false, lineStyle: { color: '#113D72', type: 'dashed' }},
        // 轴文字
        axisLabel: { color: '#0065FF', show: true, fontSize: 12, formatter:function(value:any) { return value.replace(' ', '\n') }},
      }
      let yAxis = [{ name: (attr.name? attr.name : '') + (attr.dw?attr.dw : ''), min: attr.min, max: attr.max, type: 'value', nameGap: 15,
        nameTextStyle: { padding: [60, 0, 0, 5], color: '#0065FF', fontWeight:'bold'}, axisTick: {show: false},
        axisLine: { show: true,lineStyle: {color: '#113D72', type: 'dashed' }},
        splitLine: { lineStyle: { color: '#113D72', type: 'dashed' }},
        axisLabel: { color: '#0065FF', formatter: '{value}'},
      }]
      const option = {
        grid: grid,
        tooltip: tooltip,
        color: colorArr,
        dataZoom: dataZoom,
        xAxis: xAxis,
        yAxis: yAxis,
        series: seriesArr
      };
      return option
    },

    Line_l(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      var seriesArr = []
      for (var i = 0; i <= attr.legendArr.length-1; i++) {
        colorArr.push(colorList[i].colorStart)
        seriesArr.push({ 
          name: attr.legendArr[i],
          type: 'line', 
          connectNulls:true,
          smooth: true,
          sampling: 'average', 
          large: true,
          animation: false,
          clip: true,  
          lineStyle:{ color:colorArr[i] }, 
          yAxisIndex: 0,
          data: [],
        })
      }
      let grid = [{ left: '0%', bottom: '0%', right: '6%', height: "88%", containLabel: true}]
      let tooltip = { backgroundColor:'rgba(0,0,0,0.5)',
        textStyle : { color: '#FFFFFF'}, trigger: 'item', show: true,
        formatter: function (params:any) {
          let k = params.value[0]
          let v = params.value[1]
          if(v.toString().split(".")[1] && v.toString().split(".")[1].length >3) v = Math.floor((v*100)/100)
          return '时间：' + k + '<br />值：' + v + ' ' + (attr.dw?attr.dw:'') 
        }
      }
      let dataZoom = [{ type: 'inside', show : true, realtime : true, startValue: 0, endValue: attr.chart_type==0? 20 : 100 }]
      let xAxis = { type: 'category', boundaryGap: false,
        // 轴线
        axisLine: { lineStyle: { color: '#113D72', fontSize: 12, type: 'dashed' }},
        //刻度线
        axisTick: { show: false},
        // 分割线
        splitLine: { show: false, lineStyle: { color: '#113D72', type: 'dashed' }},
        // 轴文字
        axisLabel: { color: '#0065FF', show: true, fontSize: 12, formatter:function(value:any) { return value.replace(' ', '\n') }},
      }
      let yAxis = [{ name: (attr.name? attr.name : '') + (attr.dw?attr.dw : ''), min: attr.min, max: attr.max, type: 'value', nameGap: 10,
        nameTextStyle: { padding: [0, 0, 0, -15], color: '#0065FF', fontWeight:'bold'}, axisTick: {show: false},
        axisLine: { show: true,lineStyle: {color: '#113D72', type: 'dashed' }},
        splitLine: { lineStyle: { color: '#113D72', type: 'dashed' }},
        axisLabel: { color: '#0065FF', formatter: '{value}'},
      }]
      const option = {
        grid: grid,
        tooltip: tooltip,
        color: colorArr,
        dataZoom: dataZoom,
        xAxis: xAxis,
        yAxis: yAxis,
        series: seriesArr
      };
      return option
    },

    Line0(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      var seriesArr = []
      for (var i = 0; i <= attr.legendArr.length-1; i++) {
        colorArr.push(colorList[i].colorStart)
        seriesArr.push({ 
          name: attr.legendArr[i],
          type: 'line', 
          connectNulls:true,
          smooth: true,
          sampling: 'average', 
          large: true,
          animation: false,
          clip: true,
          lineStyle:{ color:colorArr[i] }, 
          yAxisIndex: 0,
          data: [],
        })
      }
      let grid = [{ left: '0%', bottom: '0%', right: '5%', height: "90%", containLabel: true}]
      let tooltip = { backgroundColor:'rgba(0,0,0,0.5)',
        textStyle : { color: '#FFFFFF'}, trigger: 'item', show: true,
        formatter: function (params:any) {
          let k = params.value[0]
          let v = params.value[1]
          if(v.toString().split(".")[1] && v.toString().split(".")[1].length >3) v = Math.floor((v*100)/100)
          return '时间：' + k + '<br />值：' + v + ' ' + (attr.dw?attr.dw:'')
        }
      }
      let dataZoom = [{ type: 'inside', show : true, realtime : true, startValue: 0, endValue: attr.chart_type==0? 20 : 100 }]
      let xAxis = { type: 'category', boundaryGap: false,
        // 轴线
        axisLine: { lineStyle: { color: '#113D72', fontSize: 12, type: 'dashed' }},
        //刻度线
        axisTick: { show: false},
        // 分割线
        splitLine: { show: false, lineStyle: { color: '#113D72', type: 'dashed' }},
        // 轴文字
        axisLabel: { color: '#0065FF', show: true, fontSize: 12, formatter:function(value:any) { return value.replace(' ', '\n') }},
      }
      let yAxis = [{ name: (attr.name? attr.name : '') + (attr.dw?attr.dw : ''), min: attr.min, max: attr.max, type: 'value', nameGap: 15,
        nameTextStyle: { padding: [60, 0, 0, 5], color: '#0065FF', fontWeight:'bold'}, axisTick: {show: false},
        axisLine: { show: true,lineStyle: {color: '#113D72', type: 'dashed' }},
        splitLine: { lineStyle: { color: '#113D72', type: 'dashed' }},
        axisLabel: { color: '#0065FF', formatter: '{value}'},
      }]
      const option = {
        grid: grid,
        tooltip: tooltip,
        color: colorArr,
        dataZoom: dataZoom,
        xAxis: xAxis,
        yAxis: yAxis,
        series: seriesArr
      };
      return option
    },

    Line1(attr:any, data:any, pramas1:any, pramas2:any){
      var colorArr = []
      var seriesArr = []
      for (var i = 0; i <= attr.legendArr.length-1; i++) {
        colorArr.push(colorList[i].colorStart)
        seriesArr.push({ 
          name: attr.legendArr[i],
          type: 'line', 
          connectNulls:true,
          smooth: true,
          sampling: 'average', 
          large: true,
          animation: false,
          clip: true,  
          lineStyle:{ color:colorArr[i] }, 
          yAxisIndex: 0,
          data: [],
        })
      }
      let grid = [{ left: '0%', bottom: '0%', right: '5%', height: "90%", containLabel: true}]
      let tooltip = { backgroundColor:'rgba(0,0,0,0.5)',
        textStyle : { color: '#FFFFFF'}, trigger: 'item', show: true,
        formatter: function (params:any) {
          let k = params.value[0]
          let v = params.value[1]
          if(v.toString().split(".")[1] && v.toString().split(".")[1].length >3) v = Math.floor((v*100)/100)
          return '时间：' + k + '<br />值：' + v + ' ' + (attr.dw?attr.dw:'')
        }
      }
      let dataZoom = [{ type: 'inside', show : true, realtime : true, startValue: 0, endValue: attr.chart_type==0? 20 : 100 }]
      let xAxis = { type: 'category', boundaryGap: false,
        // 轴线
        axisLine: { lineStyle: { color: '#113D72', fontSize: 12, type: 'dashed' }},
        //刻度线
        axisTick: { show: false},
        // 分割线
        splitLine: { show: false, lineStyle: { color: '#113D72', type: 'dashed' }},
        // 轴文字
        axisLabel: { color: '#0065FF', show: true, fontSize: 12, formatter:function(value:any) { return value.replace(' ', '\n') }},
      }
      let yAxis = [{ name: (attr.name? attr.name : '') + (attr.dw?attr.dw : ''), min: attr.min, max: attr.max, type: 'value', nameGap: 15,
        nameTextStyle: { padding: [60, 0, 0, 5], color: '#0065FF', fontWeight:'bold'}, axisTick: {show: false},
        axisLine: { show: true,lineStyle: {color: '#113D72', type: 'dashed' }},
        splitLine: { lineStyle: { color: '#113D72', type: 'dashed' }},
        axisLabel: { color: '#0065FF', formatter: '{value}'},
      }]
      const option = {
        grid: grid,
        tooltip: tooltip,
        color: colorArr,
        dataZoom: dataZoom,
        xAxis: xAxis,
        yAxis: yAxis,
        series: seriesArr
      };
      return option
    },
  }

  // 字体自适应
  const newSize = (res:any) => {
    let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = clientWidth / 1920; //设计稿尺寸
    return res * fontSize;  //转换为 rem的布局返回出去
  }

  // 颜色列表
  const colorList = [
    { colorStart:'#0033FF', colorEnd:'#00B7FF' },
    { colorStart:'#9B42FF', colorEnd:'#FF59FC' },
    { colorStart:'#E75F5F', colorEnd:'#FFCD45' },
    { colorStart:'#f7290a', colorEnd:'#f98371' },
    { colorStart:'#CE2B8D', colorEnd:'#FF9595' },
    { colorStart:'#488BFF', colorEnd:'#9abffd' },
    { colorStart:'#26CEBA', colorEnd:'#8efaed' },
    { colorStart:'#FFC069', colorEnd:'#fadfba' },
    { colorStart:'#FD6865', colorEnd:'#f8b2b1' },
    { colorStart:'#becce9', colorEnd:'#82a0df' }
  ]
  export default setOption

